package cn.itcast.wushangxiantu.BaseAdapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import cn.itcast.wushangxiantu.R;
import cn.itcast.wushangxiantu.UserData.UserGuoZhanShenQing;

public class GuoJiaShenQingAdapter extends BaseAdapter {
    private UserGuoZhanShenQing userGuoZhanShenQing;
    private Context context;
    private ViewHolder viewHolder;

    public GuoJiaShenQingAdapter(Context context) {
        this.context = context;
    }

    public UserGuoZhanShenQing getUserGuoZhanShenQing() {
        return userGuoZhanShenQing;
    }

    public void setUserGuoZhanShenQing(UserGuoZhanShenQing userGuoZhanShenQing) {
        this.userGuoZhanShenQing = userGuoZhanShenQing;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return userGuoZhanShenQing.getShenQing().size();
    }

    @Override
    public Object getItem(int i) {
        return userGuoZhanShenQing.getShenQing().get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = View.inflate(context, R.layout.adapter_guojia_shenqing, null);
        viewHolder=new ViewHolder(view);
        viewHolder.tvName.setText(userGuoZhanShenQing.getShenQing().get(i).getGj_name());
        viewHolder.tvTime.setText(userGuoZhanShenQing.getShenQing().get(i).getTime());
        return view;
    }

    class ViewHolder {
        public View rootView;
        public TextView tvName;
        public TextView tvTime;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tvName = (TextView) rootView.findViewById(R.id.tvName);
            this.tvTime = (TextView) rootView.findViewById(R.id.tvTime);
        }

    }
}
